package trefliq.EJB.entities;

import java.io.Serializable;
import javax.persistence.*;

/**
 *
 * @author Brandon
 * 
 */
@Entity
//Modified by Eric from @NamedQuery to @NamedQueries to also have findById query for CMT bean
@NamedQueries ({
    @NamedQuery(name="findAllPeople", query="select p from Person p"),
    @NamedQuery(name="findPersonById", query = "SELECT p FROM Person p WHERE p.id = :id"),
    @NamedQuery(name="findPersonByLastName", query="select p from Person p where p.lname = :lname"),
    @NamedQuery(name="findPersonByFirstName", query="select p from Person p where p.fname = :fname"),
    @NamedQuery(name="findPersonByName", query="select p from Person p where p.fname = :fname and p.lname = :lname")
})
public class Person implements Serializable {
    private static final long serialVersionUID = 1L;
    
    @Id
    @Basic(optional = false)
//    @NotNull
    @Column(name = "ID", nullable = false)
//    @GeneratedValue(strategy=GenerationType.TABLE, generator="PERSON")
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;
    
    @Column(nullable=false, length=100)
    private String fname; 
    private String lname; 
    
    @Column(length=10)
    private String phone;
    @Column(length=100)
    private String add1; 
    private String add2; 
    private String city; 
    @Column(length=2)
    private String st;
    @Column(length=5)
    private String zip;
    @Column(length=100)
    private String email; 

    public Person() { 
    }
    
    public Person(Long id) { 
        this.id = id; 
    }
    
    public Person(Long id, String fname, String lname) { 
        this.id = id; 
        this.fname = fname; 
        this.lname = lname; 
    }
    
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getFname() {
        return fname;
    }

    public void setFname(String fname) {
        this.fname = fname;
    }
    
    public String getLname() {
        return lname;
    }

    public void setLname(String lname) {
        this.lname = lname;
    }
    
    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }
    
    public String getAdd1() {
        return add1;
    }

    public void setAdd1(String add1) {
        this.add1 = add1;
    }

    public String getAdd2() {
        return add2;
    }

    public void setAdd2(String add2) {
        this.add2 = add2;
    }

    public String getCity() {
        return city;
    }

    public void setCity(String city) {
        this.city = city;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getState() {
        return st;
    }

    public void setState(String state) {
        this.st = state;
    }

    public String getZip() {
        return zip;
    }

    public void setZip(String zip) {
        this.zip = zip;
    }
    
    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Person)) {
            return false;
        }
        Person other = (Person) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "Person{" + "id=" + id + ", fname=" + fname + ", lname=" + lname + ", phone=" + phone + ", "
                + "add1=" + add1 + ", add2=" + add2 + ", city=" + city + ", st=" + st + ", zip=" + zip + ", "
                + "email=" + email + '}';
    }

    
    
}
